package com.yoga.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yoga.model.Coach;
import com.yoga.model.search.CoachSearchBean;
import org.apache.ibatis.annotations.Mapper;

/**
 * @author yan
 * @date 2025/8/15
 */
@Mapper
public interface CoachMapper extends BaseMapper<Coach> {

    //查询
    default Page<Coach> findAll(Page<Coach> page, CoachSearchBean csb){
        LambdaQueryWrapper<Coach> qw = Wrappers.lambdaQuery(csb);
        if(csb.getHireDateFrom()!=null){
            qw.ge(Coach::getHireDate,csb.getHireDateFrom());
        }
        if(csb.getHireDateTo()!=null){
            qw.le(Coach::getHireDate,csb.getHireDateTo());
        }
        return this.selectPage(page,qw);
    }
}
